package demo9;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class test9 {
    public static void main(String[] args) {
        //当前时间
        LocalDateTime today = LocalDateTime.now();
        System.out.println(today);

        //生日时间
        LocalDateTime birDate = LocalDateTime.of(2000,1,1,0,0,0);
        System.out.println(birDate);

        System.out.println("相差的年数："+ ChronoUnit.YEARS.between(birDate,today));
        System.out.println("相差的月数："+ ChronoUnit.MONTHS.between(birDate,today));
        System.out.println("相差的周数："+ ChronoUnit.WEEKS.between(birDate,today));
        System.out.println("相差的天数："+ ChronoUnit.DAYS.between(birDate,today));
        System.out.println("相差的时数："+ ChronoUnit.MINUTES.between(birDate,today));
        System.out.println("相差的秒数："+ ChronoUnit.SECONDS.between(birDate,today));
        System.out.println("相差的毫秒数："+ ChronoUnit.MILLIS.between(birDate,today));
        System.out.println("相差的微秒数："+ ChronoUnit.MICROS.between(birDate,today));
        System.out.println("相差的纳秒数："+ ChronoUnit.NANOS.between(birDate,today));
        System.out.println("相差的半天数："+ ChronoUnit.HALF_DAYS.between(birDate,today));
        System.out.println("相差的十年数："+ ChronoUnit.DECADES.between(birDate,today));
        System.out.println("相差的世纪数："+ ChronoUnit.CENTURIES.between(birDate,today));
        System.out.println("相差的千年数："+ ChronoUnit.MILLENNIA.between(birDate,today));
        System.out.println("相差的纪元数："+ ChronoUnit.ERAS.between(birDate,today));


    }
}
